package com.xoa.controller.hr.hrEvaluate;

import com.xoa.model.hr.hrEvaluate.HrEvaluate;
import com.xoa.service.hr.hrEvaluate.HrEvaluateService;
import com.xoa.util.LimsJson;
import com.xoa.util.ToJson;
import com.xoa.util.common.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
@RequestMapping("/hrEvaluate")
public class HrEvaluateController {

@Autowired
private HrEvaluateService hrEvaluateService;

    //查看最新评价
    @RequestMapping("/evaluationView")
    public String evaluationView(HttpServletRequest request) {
        return "app/evaluationManagement/evaluationView";
    }
    //历史评价
    @RequestMapping("/staffEvaluation")
    public String staffEvaluation(HttpServletRequest request) {
        return "app/evaluationManagement/staffEvaluation";
    }

    /**
     * 查看最新评价
     */
    @RequestMapping("selectByhrEvaluateNew")
    @ResponseBody
    public LimsJson selectByhrEvaluateNew(HttpServletRequest request, Integer page, Integer pageSize, Boolean useFlag, Map map){

        return hrEvaluateService.selectByhrEvaluateNew(request, page, pageSize, useFlag, map);

    }

    /**
     * 历史评价
     */
    @RequestMapping("selectByUserId")
    @ResponseBody
    public LimsJson selectByUserId(HttpServletRequest request, Integer page, Integer pageSize, Boolean useFlag, Map map){

        return hrEvaluateService.selectByUserId(request, page, pageSize,map);


    }
    /**
     * hou
     * 查询被评价人的历次评价
     * @param request
     * @param userId  被评价人userid
     * @return
     */
    @RequestMapping("/queryHrEvaluates")
    @ResponseBody
    public ToJson<HrEvaluate> queryHrEvaluates(HttpServletRequest request,String userId){
        if(StringUtils.checkNull(userId))
            return new ToJson<>(1,"参数为空");
        return hrEvaluateService.queryHrEvaluates(request,userId);
    }


    /**
     * hou
     * 评价人添加评价
     * @param request
     * @param hrEvaluate
     * @return
     */
    @RequestMapping("/addHrEvaluates")
    @ResponseBody
    public ToJson<HrEvaluate> addHrEvaluates(HttpServletRequest request,  HrEvaluate hrEvaluate){
        return hrEvaluateService.addHrEvaluates(request,hrEvaluate);
    }

}
